#include <iostream>
#include "../sylar/log.h"
#include "../sylar/util.h"


int main(int argc, char** argv)
{
    sylar::Logger::ptr logger(new sylar::Logger);
    logger->addAppender(sylar::LogAppender::ptr(new sylar::StdoutLogAppender));

    sylar::FileLogAppender::ptr file_appender(new sylar::FileLogAppender("./log.txt"));
    
    sylar::LogFormatter::ptr fmt(new sylar::LogFormatter("%d%T%p%T%m%n"));
    file_appender->setFormatter(fmt);
    file_appender->setLevel(sylar::LogLevel::WARN);

    logger->addAppender(file_appender);

    //sylar::LogEvent::ptr event(new sylar::LogEvent(__FILE__, __LINE__, 0, sylar::GetThreadId(), sylar::GetFiberId(), time(0)));
    // std::cout << << std::endl;
    //logger->log(sylar::LogLevel::DEBUG, event);
    std::cout << "hello sylar" << std::endl;

    // SYLAR_LOG_INFO(logger) << "test1";
    // SYLAR_LOG_ERROR(logger) << "test2";
    sylar::Logger::ptr g_logger = SYLAR_LOG_NAME("abc");
    g_logger->addAppender(sylar::LogAppender::ptr(new sylar::FileLogAppender("logs/abc")));
    SYLAR_LOG_FMT_DEBUG(SYLAR_LOG_NAME("abc"), "%d test string %s ", 0, "12345");
    SYLAR_LOG_FMT_ERROR(logger, "test string %s ", "1234");
    SYLAR_LOG_FMT_WARN(logger, "test string %s ", "1234");

    auto l = sylar::LoggerMgr::GetInstance()->getLogger("xxxx");
    SYLAR_LOG_DEBUG(l) << "okkkkkk";

    return 0;
}